package colin.project.sso.server.business.observer.handler;

import cn.hutool.core.lang.Filter;
import colin.project.sso.server.business.observer.enums.OperationEventEnums;

/**
 * @Author joker
 * @Title AbstractFilter
 * @Description
 * @Date 2019/5/18 5:25 PM
 * @Since
 * @Version 1.0.0
 */
public abstract class AbstractOperationHandler implements Filter<OperationEventEnums> {


    private OperationEventEnums event;


    /**
     * 事件具体的处理
     *
     * @param source
     */
    public abstract void handle(Object source);


    /**
     * 实际处理操作
     *
     * @param event
     * @param source
     */
    public void handleServiceOperation(OperationEventEnums event, Object source) {
        this.event = event;
        if (this.accept(event)) {
            this.handle(source);
        }
    }

    /**
     * @return
     */
    public OperationEventEnums getEvent() {
        return event;
    }
}
